package modelimplementation


type CommissionedClassification struct {
	itsReceipts Dictionary
	itsCommissionRate float32
	itsSalary         float32
}
 func(c *CommissionedClassification) NewCommissionedClassification(salary float32,commissionalRate float32) *CommissionedClassification{
    c.itsSalary = salary
    c.itsCommissionRate = commissionalRate
	return c
}

func(c *CommissionedClassification) GetSalary() float32{
	return c.itsSalary
}
func(c *CommissionedClassification) AddSalesReceipt(sr SalesReceipt) *CommissionedClassification{
	c.Dictionary.itsReceipts.Add(sr.GetSaleDate(), sr)
	return c
}

func(c *CommissionedClassification) GetReceipt(date DateTime) *SalesReceipt{
	return itsReceipts[date]
}

 func(c *CommissionedClassification) GetRate() float32{
    return c.itsCommissionRate
}

func(c *CommissionedClassification) CalculatePay(pc Paycheck) float32{
	var commission float32 = 0.0
	date := c.itsReceipts.Keys
	for i := range date {
		receipt := c.itsSalary[date]
		dt1 := pc.GetPayPeriodStartDate()
		dt2 := pc.GetPayPeriodEndDate()
		if date >= dt1 && date <= dt2 {
			commission += receipt.GetAmount() * c.itsCommissionRate
		}
	}
	return (c.itsSalary + commission)
}


